package com.mk.controller;

import com.mk.beans.bo.User;
import com.mk.util.ConditionUtils;
import com.mk.util.DateUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: mk.chen
 * @Date: 2019/8/31 16:44
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/getCurrentDate")
    public Object getCurrentDate(){
        String currentDate = DateUtils.getCurrentDate();
        return currentDate;
    }

    @GetMapping("/getUser")
    public Object getUser(String name, Integer id){
        User user = new User();
        ConditionUtils.INSTANCE
                .acceptIfNotBlank(name,user::setName)
                .acceptIfNotNull(id,user::setId);
        List<User> list = new ArrayList<>();
        list.add(user);
        return list;
    }
}
